{include "Public/header"}
<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<form action="{:U('index')}" method="get" class="form-horizontal">
				search：<input type="text" name="name" class="span11" placeholder="name"
					style="width: 120px; margin-right: 10px;" value="{$_GET['name']|''}"> 
				<input type="text" name="order_id" class="span11" placeholder="Production order"
					style="width: 120px; margin-right: 10px;" value="{$_GET['order_id']|''}">
				<input type="text" name="product_name" class="span11" placeholder="P/N"
					style="width: 120px; margin-right: 10px;" value="{$_GET['product_name']|''}">
				<input type="text" name="process_name" class="span11" placeholder="Process Name"
					style="width: 120px; margin-right: 10px;" value="{$_GET['process_name']|''}">
				<input type="text" name="start_time" class="span11" placeholder="start time"
					style="width: 150px; margin-right: 10px;" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"  value="{$_GET['start_time']|''}">
				<input type="text" name="end_time" class="span11" placeholder="end time"
					style="width: 150px; margin-right: 10px;" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"  value="{$_GET['end_time']|''}">
				<input type="text" name="date" class="span11" placeholder="date"
					style="width: 150px; margin-right: 10px;" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"  value="{$_GET['date']|''}">
				<input type="submit" class="btn btn-success"
					style="margin-left: 10px;" id="search-btn" href="{:U('index')}"  value="search">
			<div class="widget-box">
				<div class="widget-title">
					<div class="left-buttons">
						<a href="{:U('save')}" id="save" class="btn btn-success btn-mini"><i
							class="icon-plus icon-white"></i>add</a>
						<input type="submit" href="{:U('output')}" id="output-btn" class="btn btn-success btn-mini" value="output" />
					</div>
				</div>
				<div class="widget-content nopadding">
					<table class="table table-bordered table-striped">
						<thead>
							<tr>
								<th>Production order</th>
								<th>Name</th>
								<th>Date</th>
								<th>Start Time</th>
                                <th>End Time</th>
                                <th>Spend Time（h）</th>
								<th>P/N</th>
								<th>Process Name</th>
								<th>Panel No</th>
								<th>Remark</th>
								<th>Input Time</th>
								<th>Input Admin</th>
								<th>Operation</th>
							</tr>
						</thead>
						<tbody>
							{foreach $list as $v}
							<tr class="gradeX">
								<td>{$v['order_id']}</td>
								<td>{$v['name']}</td>
								<td>{:date('Y-m-d',$v['start_time'])}</td>
								<td>{:date('H:i',$v['start_time'])}</td>
								<td>{:date('H:i',$v['end_time'])}</td>
								<td>{:show_time($v['start_time'],$v['end_time'])}</td>
								<td>{$v['product_name']}</td>
								<td>{$v['process_name']}</td>
								<td>{$v['panel_no']}</td>
								<td>{$v['remark']}</td>
								<td>{:date('Y-m-d H:i:s',$v['create_time'])}</td>
								<td>{$admin_list[$v['admin_id']]['name']}</td>
								<td style="text-align:center;">
									<a href="{:U('update?id='.$v['id'])}">Edit</a> - 
									<a href="{:U('delete?id='.$v['id'])}" class="delete">Delete</a>
								</td>
							</tr>
							{/foreach}
						</tbody>
						<tfoot>
							<tr>
								<td colspan="10">{$page}</td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
			</form>
		</div>
	</div>
</div>
{include "Public/footer"}
<script>
$(function(){
	$("#output-btn").click(function(){
		$("form").attr("action",$(this).attr("href"));
	});
	$("#search-btn").click(function(){
		$("form").attr("action",$(this).attr("href"));
	});
	$("form").submit(function(){
		var start_time=$("input[name='start_time']").val();
		var end_time=$("input[name='end_time']").val();
		if(start_time!=""&&end_time==""){
			dialog({
				id:"time",
				title:"error",
				content:"end time is required",
				ok:true,
				width:300
			}).show();
			return false;
		}
		if(start_time==""&&end_time!=""){
			dialog({
				id:"time",
				title:"error",
				content:"start time is required",
				ok:true,
				width:300
			}).show();
			return false;
		}
		if(end_time<start_time){
			dialog({
				id:"time",
				title:"error",
				content:"The end time must be greater than the start time",
				ok:true,
				width:300
			}).show();
			return false;
		}
	});
});
</script>